<?php

namespace App\Http\Controllers\Api\V1;

use Carbon\Carbon;
use App\Models\GoldRound;
use Illuminate\Http\JsonResponse;

class GoldProductsController extends Controller
{
	public function index(): JsonResponse
	{
		$roundId = (int)request('rid', 0);

		$round = GoldRound::sGetCache($roundId);

		if (! $round) fail('无效场次');

		$time = Carbon::now();
		/*if ($time->lt(GoldRound::todayOpenedAt($roundId))) {
			fail('暂未开场');
		} elseif ($time->gt(GoldRound::todayEndedAt($roundId))) {
			fail('已经闭场');
		}*/

		$appVersion = request("app_version");
		if($appVersion == cs("app")->pending_android_version){
			$items = collect();
		}else{

			$items = $roundId ? GoldRound::extractGoldProducts($roundId) : collect();
		}

		


		return response()->json($items);
	}
}
